This lesson is part of the Ignition with Docker course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off

LESSON

Container Basics

Description

In this lesson, we'll create a container using the official Ignition image.

Transcript

(open in window)

[00:00] In this lesson, we'll go over the basic commands needed to interact with a container. I'll assume you've already gone through the steps of setting up a Docker Engine on your machine. I'm on Windows and I've installed Docker Desktop, which is free for learning purposes. If you still need to install it, I would pause the video now and refer to the link in the description below to install Docker Desktop. Once installed we can create a container. However to create a container we'll need a container image to define how the container will be created. Let's start by finding the official Ignition image on Docker Hub. I like to start by going to the Docker Image page in our user manual. From here, I can click this link on the top of the page and it will take me to the image on Docker Hub. The main page contains an overview of the image and how to use it. When pulling an image from Docker Hub, we can request different versions of the image with different tags. If I click the tags tab, we can see those versions and the tags associated with them. I could use the latest tag to pull the most recent stable version of Ignition. But instead I'm going to manually look for the latest version, which is currently 8.1.21.

[01:13] And I'll go ahead and click it. This new page will give me information on this version of the image. It will show the layers that make it up and it will allow me to specify the OS and architecture. If I change the architecture from the drop down here, you'll see that the digest changes and this can be appended to the tag to be even more specific about the desired image. Now that we know which image we want. Let's use the command line to start up a container. I'm on Windows and I'm using PowerShell. But if you're on Linux or Mac OS you can use the terminal. In order to create our container, we'll use the following command: I'll explain the full command in a moment, but for now type "docker run -d -p 9088:8088 inductive automation/ignition: 8.1.21". And we can hit enter to start up our container.

[02:11] You should see a message that the image was unable to be found locally and it will start downloading. While it's downloading and extracting I'll explain the rest of the command. The first part of the command "docker run" will create a container and then we have some options. "-d" will run the container in detached mode or as a background process. The next option "-p" will publish all the ports to the host interfaces. So in this command we're mapping the container port 8088, the default ignition port, to the host port 9088. The last part of the command is the image that the container will be derived from, which we found on Docker Hub, followed by a colon and the tag for the specific version. Once it's finished we should have Ignition running in a container. We can test this by going into our web browser typing in localhost and then the host port we mapped 9088.

[03:04] If we want to look at the status of our containers we can use the command "docker ps". This will show us a list of the containers that are currently running, the images they're derived from, and the current statuses. And we see here that our Ignition container is currently up and healthy. This is also useful for figuring out the ID of our container as we may need that for other commands. Let's say we wanted to run "docker inspect" on our container. This would give us low level information about whatever object we're inspecting. We can copy and paste the container ID here and use it in the command to reference that specific container. As you can see this will give us the additional information if we wanted to learn more about the image or do any sort of troubleshooting later. I'll go ahead and clear this text to clean things up. One important note about containers is that they're immutable. In other words, they can't be modified. If you want to spin up our container with different settings, we need to create a brand new one.

[04:03] We'll be doing that later. So let's go ahead and remove the one that we just created. In order to do that, we can use "docker rm" and then specify our container with its ID. We should see an error here telling us that we can't remove a running container. So let's go ahead and stop it. We'll do this with "docker stop". And then once again, we can specify our container with its ID. To make sure that it's stopped we can use "docker ps" again to check the status of our containers. So let's go ahead and do that. By default, this command only returns running containers. And since we don't see it, we can assume that it stopped. However, if we wanted to start it back up we might want to see all of our containers to grab that ID again. To learn more about a command we can append "--help". Once we do that, we'll see a description of the command in the available options. The first option "-a" will show all containers and we can even see a note here about the default behavior. So let's try "docker ps" again with the "-a" option.

[05:06] And this time we'll see our container and under status, we see that it exited and it's no longer running. Now let's try removing it again. We'll run another "docker ps -a" to confirm. And there we go. We'll end the lesson here now that we have a basic understanding of creating containers along with stopping and removing them. In the next lesson, we'll look at some additional configurations for our container as well as how to pass runtime arguments to Ignition.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.